<template>
	<div>
		<swiper circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
			<swiper-item v-for="(item,index) in imgArr" :key="index">
				<view>
					<image :src="item.img" mode=""></image>
				</view>
			</swiper-item>
		</swiper>
		<view v-for="(item,index) in dataArr" :key="index">
			<view>
				<text style="color: red;">￥{{item.sell_price}}&nbsp;&nbsp;</text><text style="text-decoration: line-through;">￥{{item.market_price}}</text>
			</view>
			<view style="border-bottom: solid 3px #808080; height: 40px;">
				{{item.title}}
			</view>
			<view>
				{{item.goods_no}}
			</view>
			<view style="border-bottom: solid 3px #808080; height: 40px;">
				{{item.stock_quantity}}
			</view>
			<view>
				详情介绍
			</view>
			<rich-text :nodes="item.content" v-for="(item,index) in xiangxi" :key="index"></rich-text>
		</view>
		<view class="bottom">
			<view class="">
				客服
			</view>
			<view class="">
				店铺
			</view>
			<view class="">
				购物车
			</view>
			<view style=" display: flex;">
				<view class="add">
					加入购物车
				</view>
				<view class="buy">
					立即购买
				</view>
			</view>

		</view>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				duration: 500,
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				imgArr: [],
				dataArr: [],
				xiangxi: []
			}
		},
		onLoad(option) {
			uni.request({
					url: `http://localhost:8082/api/getthumimages/${option.id}`,
					method: 'GET',
					success: (data) => {
						console.log(data)
						this.imgArr = data.data.message
					}
				}),
				uni.request({
					url: `http://localhost:8082/api/goods/getinfo/${option.id}`,
					method: 'GET',
					success: (data) => {
						console.log(data)
						this.dataArr = data.data.message
					}
				}),
				uni.request({
					url: `http://localhost:8082/api/goods/getdesc/${option.id}`,
					method: 'GET',
					success: (data) => {
						console.log(data)
						this.xiangxi = data.data.message
					}
				})
		}
	}
</script>

<style scoped>
	swiper {
		width: 100%;
		height: 350px;
	}

	.bottom {
		width: 100%;
		height: 60px;
		background-color: white;
		position: fixed;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: space-around;
	}

	.add {
		width: 100px;
		height: 40px;
		line-height: 40px;
		background-color: #FF0000;
		color: white;
		text-align: center;
		border-radius: 50px 0px 0px 50px;
	}

	.buy {
		width: 100px;
		height: 40px;
		line-height: 40px;
		background-color: #FFA200;
		color: white;
		text-align: center;
		border-radius: 0px 50px 50px 0px;
	}
</style>
